#ifndef RECTANGLE_H
#define RECTANGLE_H
#include "StompedReality/Core.h"
#include "Vector2.h"

StaticRegDummy( Rectangle )

namespace StompedReality
{
namespace Math
{

struct RectangleReg
{
  static int registeType( );
};

class DLL_EXPORT Rectangle
{
  friend struct RectangleReg;

 private:

  StompedReality::Math::Vector2 m_Center;
  StompedReality::Math::Vector2 m_HalfSize;

  void Initialize ( StompedReality::Math::Vector2 center, StompedReality::Math::Vector2 halfsize );

 public:

  //! \brief	Constuctor.
  Rectangle ( );

  //! \brief	Constuctor.
  //! \param	center		The rectangles center.
  //! \param	halfsize	The rectangle half size.
  Rectangle ( StompedReality::Math::Vector2 center, StompedReality::Math::Vector2 halfsize );

  //! \brief	Constuctor.
  //! \param	x		The rectangles centers x component.
  //! \param	x		The rectangles centers y component.
  //! \param	w		The rectangles half size x component.
  //! \param	h		The rectangles half size y component.
  Rectangle ( float x, float y, float w, float h );

  //! \brief	Destuctor.
  virtual ~Rectangle( );

  //! \brief	Center getter.
  StompedReality::Math::Vector2 GetCenter ( )
  {
    return this->m_Center;
  }

  //! \brief	Half size getter.
  StompedReality::Math::Vector2 GetHalfSize ( )
  {
    return this->m_HalfSize;
  }

  //! \brief	Width getter.
  float Width( )
  {
    return this->m_HalfSize.GetX( ) * 2;
  }

  //! \brief	Height getter.
  float Height( )
  {
    return this->m_HalfSize.GetY( ) * 2;
  }

  //! \brief	Rectangles top.
  float Top( )
  {
    return this->m_Center.GetY( ) - this->m_HalfSize.GetY( );
  }

  //! \brief	Rectangles left.
  float Left( )
  {
    return this->m_Center.GetX( ) - this->m_HalfSize.GetX( );
  }

  //! \brief	Rectangles bottom.
  float Bottom( )
  {
    return this->m_Center.GetY( ) + this->m_HalfSize.GetY( );
  }

  //! \brief	Rectangles right.
  float Right( )
  {
    return this->m_Center.GetX( ) + this->m_HalfSize.GetX( );
  }

  //! \brief	Rectangle size getter.
  StompedReality::Math::Vector2 getSize( )
  {
    return this->m_HalfSize * 2;
  }

  //! \brief	Translates rectangle by vector.
  //! \param	translation		The translation.
  void Translate ( StompedReality::Math::Vector2* translation )
  {
    this->m_Center.Add ( translation );
  }

  //! \brief	Translates rectangle by x,y.
  //! \param	x		X.
  //! \param	y		Y.
  void Translate ( float x, float y )
  {
    this->m_Center.Add ( x, y );
  }

  //! \brief	Checks if rectangle contains other rectangle.
  //! \param	other	The other rectangle.
  //! \return	True if contains other rectangle otherwise false.
  bool Contains ( StompedReality::Math::Rectangle* other );

  //! \brief	Checks if rectangle contains a point.
  //! \param	point	The point.
  //! \return	True if contains the point otherwise false.
  bool Contains ( StompedReality::Math::Vector2* point );

  //! \brief	Checks if rectangle intersects with other rectangle.
  //! \param	other	The other rectangle.
  //! \return	True if intersects with other rectangle otherwise false.
  bool Instersects ( StompedReality::Math::Rectangle* other );

  static bool Contains ( StompedReality::Math::Vector2 pos, StompedReality::Math::Vector2 size,
                         StompedReality::Math::Vector2 point );
};

}
}
#endif // RECTANGLE_H
